import request from '@/utils/request';
import requestSolo from '@/utils/request-solo';

// 获取加密器
export function getSupportedCryptInfos(query, data) {
  return request({
    url: '/framework/crypt/supportSymmetricTypes',
    method: 'get',
    params: query,
    data: data,
    hmacReq: true,
    encryptReq: true,
    decryptRes: true,
  });
}

// 校验XML格式
export function schemaValidate(data) {
  return request({
    url: '/web/db/api/apiDetail/xmlValidator',
    method: 'post',
    data: data,
    hmacReq: true,
    encryptReq: true,
    decryptRes: true,
  });
}

// SQL模板测试结果
export function dataApiBoundSql(id, params, data, hasEncrypt, encryptType, encryptKey) {
  return requestSolo({
    url: '/web/db/api/dataApi/dataApiBoundSql/' + id,
    method: 'post',
    params,
    data,
    encryptReq: hasEncrypt,
    decryptRes: hasEncrypt,
    encryptType,
    encryptKey,
  });
}

// API接口返回结果
export function dataApi(method = 'get', url, data, hasEncrypt, encryptType, encryptKey) {
  return requestSolo({
    url: `/web/db/api/dataApi/${url}`,
    method,
    data,
    encryptReq: hasEncrypt,
    decryptRes: hasEncrypt,
    encryptType,
    encryptKey,
  });
}
